﻿<Window x:Class="SuperQuery.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="SuperQuery" Height="350" Width="525" Icon="Icons/SuperQuery.ico"
        TextOptions.TextFormattingMode="Display" WindowState="Maximized" Closing="Window_Closing">
    
    <Window.Resources>
        <!--Tab item header template for tab item with close button-->
        <DataTemplate x:Key="ClosableTabItem" DataType="{x:Type TabItem}">
            <StackPanel Orientation="Horizontal">
                <Label Margin="0,2,0,0"  Content="{Binding RelativeSource={RelativeSource AncestorType={x:Type TabItem}},Path=Header}"/>
                <Button Name="btnTabClose" Click="btnTabClose_Click" MinWidth="0"
                        Tag="{Binding RelativeSource={RelativeSource AncestorType={x:Type TabItem}},Path=Content}">X</Button>
            </StackPanel>
        </DataTemplate>
    </Window.Resources>
    
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        
        <!--Main Menu-->
        <Menu IsMainMenu="True" Grid.Row="0">
            <MenuItem Header="_File">
                <MenuItem Header="_New Query" Name="mnuNewQuery" Click="mnuNewQuery_Click"/>
                <MenuItem Header="_Open Query..." Name="mnuOpenQupery" Click="mnuOpenQupery_Click"/>
                <Separator/>
                <MenuItem Header="_Save Query" Name="mnuSaveQuery" Click="mnuSaveQuery_Click" />
                <MenuItem Header="_Save Query As..." Name="mnuSaveQueryAs" Click="mnuSaveQueryAs_Click"/>
                <Separator/>
                <MenuItem Header="_Quit" Name="mnuQuit" Click="mnuQuit_Click"/>
            </MenuItem>
            <MenuItem Header="_Edit">
                <MenuItem Header="_Cut" Name="mnuCut" Command="Cut" />
                <MenuItem Header="_Copy" Name="mnuCopy" Command="Copy" />
                <MenuItem Header="_Paste" Name="mnuPaste" Command="Paste" />
                <Separator/>
                <MenuItem Header="_Select All" Name="mnuSelectAll" Command="SelectAll" />
            </MenuItem>
            <MenuItem Header="_Query">
                <MenuItem Header="_Clear Database List" Name="mnuClearDatabaseList" Click="mnuClearDatabaseList_Click" IsEnabled="{Binding Path=SelectedQueryTab.EditorEnabled}"/>
                <MenuItem Header="_Open Database List..." Name="mnuOpenDatabaseList" Click="mnuOpenDatabaseList_Click" IsEnabled="{Binding Path=SelectedQueryTab.EditorEnabled}"/>
                <Separator/>
                <MenuItem Header="_Save Database List" Name="mnuSaveDatabaseList" Click="mnuSaveDatabaseList_Click" IsEnabled="{Binding Path=SelectedQueryTab.EditorEnabled}"/>
                <MenuItem Header="_Save Database List As..." Name="mnuSaveDatabaseListAs" Click="mnuSaveDatabaseListAs_Click" IsEnabled="{Binding Path=SelectedQueryTab.EditorEnabled}"/>
                <Separator/>
                <MenuItem Header="_Export Result Set..." Name="mnuExportResultSet" Click="mnuExportResultSet_Click" IsEnabled="{Binding Path=SelectedQueryTab.EditorEnabled}"/>
            </MenuItem>
            <MenuItem Header="_Settings" Visibility="Collapsed">
                <MenuItem Header="_Save settings now" Name="mnuSaveSettingsNow" Click="mnuSaveSettingsNow_Click"/>
            </MenuItem>
            <MenuItem Header="_Help">
                <MenuItem Header="_Help" Name="mnuHelp" Click="mnuHelp_Click"/>
                <Separator/>
                <MenuItem Header="_About" Name="mnuAbout" Click="mnuAbout_Click"/>
            </MenuItem>
        </Menu>

        <!--Tab control to hold the queries and the results-->
        <TabControl x:Name="tabQueries" Grid.Row="1" SelectionChanged="tabQueries_SelectionChanged">
        </TabControl>
    </Grid>
</Window>
